<template>
	<view class="container">
		<view class="header">
			<!-- <image src="@/static/missing-face.png" mode="aspectFit" class="image"></image> -->
		</view>
		<view class="login-btn">
			<button open-type="getPhoneNumber" @getphonenumber="getphonenumber">绑定手机号</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {}
		},
		onShow() {
			uni.hideHomeButton()
		},
		methods: {
			getphonenumber(e) {
				if (e.detail.code) {
					console.log(e.detail.code)
					this.$post("/user/mobile_auth", {
						code: e.detail.code
					}).then(res => {
						if (res.code == 200) {
							this.getUserinfo()
						}
					})
				}
			},
			getUserinfo() {
				this.$post("/user/userinfo", {}).then(res => {
					if (res.data.group_id == 1) {
						//工人
						uni.redirectTo({
							url: "/pages/staff/index/index"
						})
					} else if (res.data.group_id == 2) {
						//管理员
						uni.redirectTo({
							url: "/pages/admin/index/index"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
		font-size: 32rpx;
		text-align: center;
	}

	.container {
		padding: 0 60rpx;
	}

	.header {
		padding: 80rpx 0 50rpx;

		image {
			width: 200rpx;
			height: 200rpx;
		}
	}

	.title {
		color: #585858;
		font-size: 34rpx;
		margin-bottom: 40rpx;
	}

	.subtitle {
		color: #888;
		margin-bottom: 88rpx;
		font-size: 28rpx;
	}

	.login-btn {
		padding: 0 20rpx;
	}

	button::after {
		border: none;
	}

	.login-btn button {
		height: 88rpx;
		line-height: 88rpx;
		background: $main-color;
		color: #fff;
		font-size: 32rpx;
		border-radius: 16rpx;
		text-align: center;
	}
</style>